/*
 * Copyright (C), 2014-2015, 杭州小卡科技有限公司
 * FileName: InsCorpFactory.java
 * Author:   muxing
 * Date:    2015/10/20 16:39
 * Description:
 */
package com.xiaoka.ins.corp.common.factory.base;

import com.xiaoka.freework.help.api.ApiException;
import com.xiaoka.ins.corp.common.constant.InsConstant;
import com.xiaoka.ins.corp.common.dto.base.InsParameter;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * InsCorpFactory 静态工厂方法，根据代码生成不同保险代理调用
 * 
 * @author muxing
 * @date 2015/10/20
 */
@Configuration("insCorpFactory")
public class InsCorpFactory {

	@Resource(name = "aicsApiService")
	InsCorpSerice aicsApiService;

	@Resource(name = "cicpApiService")
	InsCorpSerice cicpApiService;

	public InsCorpSerice creat(InsParameter insParameter) {
		InsCorpSerice insCorpSerice = null;
		switch (insParameter.getInsCorpType()) {
		case InsConstant.INSCORP_CICP:
			insCorpSerice = cicpApiService;
			break;
		case InsConstant.INSCORP_AICS:
			insCorpSerice = aicsApiService;
			break;
		default:
			// 不支持的保险公司接口
			throw new ApiException("1", "222");
		}
		return insCorpSerice;
	}

}
